package com.sleep.cloudstreamdemo.producer;

import com.sleep.cloudstreamdemo.domian.DemoMessage;
import lombok.AllArgsConstructor;
import org.springframework.cloud.stream.function.StreamBridge;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @ClassName DemoProducer
 * @Description TODO
 * @Author 郭敖
 * @Date 2024年04月18日 9:39
 * @Version 1.0
 */
@Component
@AllArgsConstructor
public class DemoProducer {
    private final StreamBridge streamBridge;

    public void sendMessage(DemoMessage message){
        streamBridge.send("demo-out-0", MessageBuilder.withPayload(message));
    }

    public void sendLogMessage(DemoMessage message){
        streamBridge.send("log-out-0", MessageBuilder.withPayload(message));
    }

}
